# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: team/kde <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-applications
pkgname=akonadi-search
pkgver=23.08.4
pkgrel=0
pkgdesc="Libraries and daemons to implement searching in Akonadi"
# armhf blocked by extra-cmake-modules
# riscv64 blocked by akonadi
# s390x blocked by multiple KDE Frameworks
# ppc64le blocked by qt5-qtwebengine -> akonadi
arch="all !armhf !s390x !riscv64 !ppc64le"
url="https://community.kde.org/KDE_PIM"
license="( GPL-2.0-only OR GPL-3.0-only ) AND ( LGPL-2.1-only OR LGPL-3.0-only )"
depends_dev="
	akonadi-dev>=$pkgver
	akonadi-mime-dev>=$pkgver
	kcalendarcore5-dev
	kcmutils5-dev
	kconfig5-dev
	kcontacts5-dev
	kcrash5-dev
	kdbusaddons5-dev
	ki18n5-dev
	kio5-dev
	kmime-dev
	krunner5-dev
	qt5-qtbase-dev
	xapian-core-dev
	"
makedepends="$depends_dev
	extra-cmake-modules
	samurai
	"
checkdepends="xvfb-run"
_repo_url="https://invent.kde.org/pim/akonadi-search.git"
source="https://download.kde.org/stable/release-service/$pkgver/src/akonadi-search-$pkgver.tar.xz"
subpackages="$pkgname-dev $pkgname-lang"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib
	cmake --build build
}

check() {
	cd build

	# akonadi-sqlite-schedulertest, konadi-sqlite-collectionindexingjobtest,
	# akonadi-mysql-schedulertest and akonadi-mysql-collectionindexingjobtest
	# require running dbus server

	# Prevent the lines using more than 80 characters by looping
	local skipped_tests="("
	local tests="
		akonadi-sqlite-scheduler
		akonadi-sqlite-collectionindexingjob
		akonadi-mysql-scheduler
		akonadi-mysql-collectionindexingjob"
	for test in $tests; do
		skipped_tests="$skipped_tests|$test"
	done
	skipped_tests="$skipped_tests)test"
	CTEST_OUTPUT_ON_FAILURE=TRUE xvfb-run ctest -E "$skipped_tests"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}
sha512sums="
a6945a19b9a3d570a573260c48d81f3dd5344b3fe64947f8b3cbf50c46303de7fc5d97afa2c6016f75cddb6f1f1fead270a4a6979e576de6778e4fe7fa2716a8  akonadi-search-23.08.4.tar.xz
"
